//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<dict.h>
///	@path	~/src/lib/utilities/
///	@date	2007/06/19
///	@desc	Dictionary encapsulation.

#pragma once

#include "xeres.h"

// STL
#include <hash_map>

namespace xeres {

	/*!
		\class	dict
		\brief	Dictionary encapsulation.
		\details
			General dictionary class, hash keys & map them to values.<BR>
			This class encapsulates STL's hash_map template, to match some demanded behavior in engine.
	*/
	template<
		typename _Key ,
		typename _Val
	> class dict
	: public
#ifdef	_STLPORT_VERSION
		// using STL-port
		std::hash_map< _Key , _Val >
#else
		// using VC's STL
		stdext::hash_map< _Key , _Val >
#endif
	{
	public:

		/// \name Dictionary Manipulation
		//@{

		/// \brief Insert element.
		void insert( const _Key& key , const _Val& val )
		{
			__super::insert( std::make_pair<_Key,_Val>( key , val ) );
		}
		//@}

		/// \name Dictionary Query
		//@{

		/// \brief Return true if dictionary has an element matches the key.
		bool has_key( const _Key& key ) const
		{
			return find( key ) != end();
		}

		//@}
	};

} // namespace xeres
